const express = require('express');
const router = express.Router();
const battleRoomController = require('../controllers/battleRoomController');
const userController = require('../controllers/userController');

// 校验token
router.use(userController.verifyToken);

// 创建对战房间
router.post('/create', battleRoomController.createBattleRoom);

// 提交对战答案
router.post('/submit', battleRoomController.submitBattleAnswer);

// 获取对战结果
router.get('/result/:id', battleRoomController.getBattleResult);

// 获取排行榜
router.get('/ranking', battleRoomController.getRankingList);

// 获取用户排名
router.get('/userRank', battleRoomController.getUserRank);

// 创建练习赛
router.post('/practice/create', battleRoomController.createPractice);

// 提交练习赛答案
router.post('/practice/submit', battleRoomController.submitPracticeAnswer);

// 获取房间题目列表
router.get('/questions/:roomId', battleRoomController.getRoomQuestions);

// 获取用户对战历史
router.get('/history', battleRoomController.getUserBattleHistory);

// 获取对战房间列表
router.get('/rooms', battleRoomController.getBattleRoomList);

module.exports = router; 